<template>
  <div>
    <div class="search-pannel">
      <el-form class="search-form" ref="searchForm" label-position="top" :model="searchData">
        <el-col :span="6">
          <el-form-item label="状态" prop="status">
            <el-select v-model="searchData.status">
              <el-option v-for="item in leaseStatusList" :key="item.value" :value="item.value"
                         :label="item.text"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="所属房屋" prop="houseId">
            <el-select v-model="searchData.houseId">
              <el-option v-for="item in myHouseList" :key="item.id" :value="item.id"
                         :label="item.name"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="创建时间" prop="createdAt">
            <el-date-picker v-model="searchData.createdAt" type="daterange"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <div class="button-list">
            <el-button type="primary" @click="onSearch">搜 索</el-button>
            <el-button @click="reset">重 置</el-button>
          </div>
        </el-col>
      </el-form>
    </div>
    <page-table
        ref="pageTable"
        showIndex
        @currentChange="currentChange"
        @sizeChange="sizeChange"
        @sortChange="sortChange"
        :loading="loading"
        :data="data"
        :total="count"
        :page="pageIndex"
        :pageSize="pageSize"
    >
      <el-table-column prop="userNickName" label="发起人"></el-table-column>
      <el-table-column prop="houseOwnerNickName" label="房主"></el-table-column>
      <el-table-column sortable="custom" prop="startTime" label="开始时间">
        <template slot-scope="{row}">
          {{row.startTime | timeFilter('yyyy-MM-dd')}}
        </template>
      </el-table-column>
      <el-table-column sortable="custom" prop="endTime" label="结束时间">
        <template slot-scope="{row}">
          {{row.endTime | timeFilter('yyyy-MM-dd')}}
        </template>
      </el-table-column>
      <el-table-column prop="houseName" label="房屋标题"></el-table-column>
      <el-table-column sortable="custom" prop="createdAt" label="创建时间">
        <template slot-scope="{row}">
          {{row.createdAt | timeFilter}}
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="{row}">
          {{row.status | leaseStatusFilter}}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="{row}">
          <el-button type="text" @click="toDetail(row.id)">详情</el-button>
        </template>
      </el-table-column>
    </page-table>
    <detail-dialog :visible="detailVisible" @close="detailClose" :opId="opId" />
  </div>
</template>

<script>
import { initTable, getLeaseStatus, getAllMyHouse } from '@/mixins'
import { _getList } from './store'

export default {
  name: 'leaseSetting',
  mixins: [initTable, getLeaseStatus, getAllMyHouse],
  data() {
    return {
      searchData: {
        status: '',
        createdAt: [],
        houseId: ''
      },
      initFunc: _getList
    }
  },
  components: {
    'detailDialog': () => import('../components/detailDialog')
  }
}
</script>

<style scoped>

</style>
